﻿using System.Data.Linq;

namespace BotModels
{
    public class LibraryDataContext : DataContext
    {
        private const string CONNECTION_STRING = @"isostore:/LibraryDB.sdf";

        public LibraryDataContext() : base(CONNECTION_STRING)
        {
            CheckDatabase();
        }

        public LibraryDataContext(string connectionString) : base(connectionString)
        {
            CheckDatabase();
        }

        public Table<Bot> Bots
        {
            get
            {
                return GetTable<Bot>();
            }
        }

        private void CheckDatabase()
        {
            if (!DatabaseExists())
            {
                CreateDatabase();
            }
        }
    }
}
